package com.lock;

import com.sun.org.apache.xpath.internal.operations.Or;
import org.junit.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;

/**
 * @author: csh
 * @Date: 2021/12/18 22:09
 * @Description:
 */
public class ActiveUse1 {
    public static void main(String[] args) {
        Order order = new Order();
    }

    @Test
    public void test1(){
        ObjectOutputStream oos = null;
        try {
            oos = new ObjectOutputStream(new FileOutputStream("order.dat"));
            oos.writeObject(new Order());
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if(oos!=null){
                try {
                    oos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public void test2(){
        ObjectOutputStream oos = null;
        try {
            oos = new ObjectOutputStream(new FileOutputStream("order.dat"));
            oos.writeObject(new Order());
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if(oos!=null){
                try {
                    oos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    @Test
    public void test3(){
        Order.method();
    }

}

class Order implements Serializable {
    static {
        System.out.println("Order类的初始化过程");
    }

    public static void method(){
        System.out.println("Order method 方法");
    }
}
